<table width="100%" border=0 cellpadding=0 cellspacing=0>
  <tr>
    <td>
      <table cellpadding="3" cellspacing="0" border="0" width="100%">
        <tr bgcolor="#7EC1F3">
          <td align=left>
            <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?t=<%=(currentDate.getTime().getTime()-1000*60*60*24)%>">
                <img SRC="<%=BoxStatic.imageDir%>cal_left.gif" WIDTH="11" HEIGHT="11" BORDER="0">Previous day</a>
          </td>
          <td align="center">
            <font face="Arial,Helvetica" SIZE="+1"><b>
            	<%=StringUtil.getDateTimeFormatString(sec.getTimeZone(), BoxStatic.VERYLONG_DATE_FORMAT, currentDate.getTime())%>
              </b></font>
          </td>
          <td align="right">
             <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?t=<%=(currentDate.getTime().getTime()+1000*60*60*24)%>">Next day<img
            SRC="<%=BoxStatic.imageDir%>cal_right.gif" WIDTH="11" HEIGHT="11" BORDER="0"></a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td valign="top">
      <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr bgcolor="#dddddd">
          <td>
            <table width="100%" cellpadding="3" cellspacing="1" border="0">
<%
  Vector v = BoxCalHome.getColumnedEntries(curID, currentDate, curCalUserID);
  long curTime = BoxCalHome.getEarliestTime(workStartHour, currentDate, v);
  long endTime = BoxCalHome.getLatestTime(workEndHour, currentDate, v);
//out.print("start Time = " + new Timestamp(curTime));
//out.print("end Time = " + new Timestamp(endTime));

  int columns = 1;
  if (v.size() > 0)
    columns = v.size();
  int width = 100/columns;
//out.print(v);

//out.print("columns = " + columns + "  width = " + width);
  Vector RowSpanBuffer = new Vector(columns);
  for(int i = 0; i < columns; i++)
  {
    RowSpanBuffer.add(i, new Integer(0));
  }

  Iterator it = BoxCalHome.getAllDayEntries(curID, currentDate, curCalUserID);
  if (it != null && it.hasNext())
  {
    while (it.hasNext())
    {
      BoxCalendarEntry entry = (BoxCalendarEntry) it.next();
      if (entry != null)
      {
%>
        <tr>
          <th VALIGN="top" ALIGN="right" NOWRAP WIDTH="1%" BGCOLOR="#eeeeee">All day</th>
          <td BGCOLOR="#ffffff" COLSPAN="<%=columns%>" WIDTH="100%" VALIGN="top">
	            <Calendar:CalendarEntry timezone="<%=sec.getTimeZone()%>" viewerid="<%=curID%>" showtime="false" showdelete="true" calendarentry="<%=entry%>"/>
				  </td>
        </tr>
<%
      }
    }
  }
  while ( curTime < endTime )
  {
%>
    <tr>
      <th VALIGN="top" ALIGN="right" NOWRAP WIDTH="1%" BGCOLOR="#eeeeee">
<%
				if (curCalUserID == curID)
  			{
%>
          <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?SubmitEdit=edit&t=<%=curTime%>"><%=StringUtil.getDateTimeFormatString(sec.getTimeZone(), BoxStatic.SHORT_TIME_FORMAT, curTime)%></a>
<%
  			}
        else
				{
          out.print(StringUtil.getDateTimeFormatString(sec.getTimeZone(), BoxStatic.SHORT_TIME_FORMAT, curTime));
				}
%>
      </th>
<%
    for(int i = 0; i < columns; i++)
    {
      Vector vv = null;
      if ( i < v.size())
        vv = (Vector)v.elementAt(i);
      if ( vv != null )
      {
        BoxCalendarEntry bean = BoxCalHome.findEntryBetween(vv, sec.getTimeZone(), curTime, curTime + 1000*60*60);
        if ( bean != null)
        {
          Integer rows = new Integer(BoxCalHome.getEntryRows(bean, sec.getTimeZone()));
          RowSpanBuffer.setElementAt(rows,i);
%>
            <td BGCOLOR="#ffffff" ROWSPAN="<%=rows.intValue()%>" WIDTH="<%=width%>%" VALIGN="top">
	            <Calendar:CalendarEntry timezone="<%=sec.getTimeZone()%>" viewerid="<%=curID%>" showtime="true" showdelete="true" calendarentry="<%=bean%>"/>
            </td>
<%
      }
        else
        {
          Integer rows = (Integer) RowSpanBuffer.elementAt(i);
          if ( rows != null && rows.intValue()>1)
          {
            RowSpanBuffer.setElementAt(new Integer(rows.intValue()-1),i);
          }
          else
          {
%>
            <td BGCOLOR="#eeeeee" WIDTH="<%=width%>%" COLSPAN="1"><br>
            </td>
<%
          }
        }
      }
      else
      {
%>
            <td BGCOLOR="#eeeeee" WIDTH="<%=width%>%" COLSPAN="1"><br>
            </td>
<%
      }
    } //end for
    out.print(" </tr>");
    curTime += 1000*60*60;
//    curTime.add(Calendar.HOUR_OF_DAY,1);
  } //end while
%>
        </table>
        </td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td align="middle"><font color="#ffffff">___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
    ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ </font></td>
  </tr>
</table>
